clear all
version 15
set maxvar 20000



**********************************************************************
* Inventor information
**********************************************************************
*Datastructure: inventor1 is always the deceased inventor, inventor2 to inventor18 are the co-inventors
use "C:\replication\data\work\analysis_sample.dta", clear
* use "C:\replication\data\analysis_sample.dta", clear // use this dataset instead if you didn't create analysis_sample.dta from scratch with create_sample.do
************************************************************


************************************************************
* Distances between inventors
************************************************************
* Minimal distance between cited and citing inventors
foreach num_cited of numlist 1/18 {
egen min_distance`num_cited' = rowmin(distance_`num_cited'_*)
label variable min_distance`num_cited' "minimal distance between cited inventor and citing inventors"
}
************************************************************

************************************************************
* Time
************************************************************
* Year since grant
gen year_since_grant = .
foreach year of numlist 1/15 {
replace year_since_grant = `year' if appl_date_citing > grant_date_cited + 365*(`year'-1) & appl_date_citing <= grant_date_cited + 365*`year'
label variable year_since_grant "year since grant of cited patent"
}
************************************************************

************************************************************
* Cites within radius
************************************************************
* Cites within radius; all, within 5, 10 and 15 years; no self cites 
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
foreach num of numlist 1/18 {
gen dummy_nsc_mindis`dis'_`num' = min_distance`num' < `dis' if min_distance`num' ~= . & self_cite == 0
gen dummy_nsc_mindis`dis'_within15y_`num' = min_distance`num' < `dis' if min_distance`num' ~= . & self_cite == 0 & year_since_grant <= 15
gen dummy_nsc_mindis`dis'_within10y_`num' = min_distance`num' < `dis' if min_distance`num' ~= . & self_cite == 0 & year_since_grant <= 10
gen dummy_nsc_mindis`dis'_within5y_`num' = min_distance`num' < `dis' if min_distance`num' ~= . & self_cite == 0 & year_since_grant <= 5
} 
}
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
foreach num of numlist 1/18 {
bysort cited: egen count_nsc_mindis`dis'_`num' = total(dummy_nsc_mindis`dis'_`num') if min_distance`num' ~= .
label variable count_nsc_mindis`dis'_`num' "no of cites within `dis' miles"
bysort cited: egen count_nsc_mindis`dis'_within15y_`num' = total(dummy_nsc_mindis`dis'_within15y_`num') if min_distance`num' ~= .
label variable count_nsc_mindis`dis'_within15y_`num' "no of cites within `dis' miles and 15 years"
bysort cited: egen count_nsc_mindis`dis'_within10y_`num' = total(dummy_nsc_mindis`dis'_within10y_`num') if min_distance`num' ~= .
label variable count_nsc_mindis`dis'_within10y_`num' "no of cites within `dis' miles and 10 years"
bysort cited: egen count_nsc_mindis`dis'_within5y_`num' = total(dummy_nsc_mindis`dis'_within5y_`num') if min_distance`num' ~= .
label variable count_nsc_mindis`dis'_within5y_`num' "no of cites within `dis' miles and 5 years"
}
}
drop dummy_*

* Cites within 20 miles and year after grant; no self cites
foreach num of numlist 1/18 {
foreach year of numlist 1/10 {
gen dummy_nsc_mindis20_y`year'_`num' = min_distance`num' < 20 if min_distance`num' ~= . & self_cite == 0 & year_since_grant == `year'
}
}
foreach num of numlist 1/18 {
foreach year of numlist 1/10 {
bysort cited: egen count_nsc_mindis20_y`year'_`num' = total(dummy_nsc_mindis20_y`year'_`num') if min_distance`num' ~= .
label variable count_nsc_mindis20_y`year'_`num' "no of cites in year `year' after grant within 20 miles"
}
}
drop dummy_*

* Cites within radius; all, within 5, 10 and 15 years; self cites included 
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
foreach num of numlist 1/18 {
gen dummy_mindis`dis'_`num' = min_distance`num' < `dis' if min_distance`num' ~= .
gen dummy_mindis`dis'_within15y_`num' = min_distance`num' < `dis' if min_distance`num' ~= . & year_since_grant <= 15
gen dummy_mindis`dis'_within10y_`num' = min_distance`num' < `dis' if min_distance`num' ~= . & year_since_grant <= 10
gen dummy_mindis`dis'_within5y_`num' = min_distance`num' < `dis' if min_distance`num' ~= . & year_since_grant <= 5
} 
}
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
foreach num of numlist 1/18 {
bysort cited: egen count_mindis`dis'_`num' = total(dummy_mindis`dis'_`num') if min_distance`num' ~= .
label variable count_mindis`dis'_`num' "no of cites within `dis' miles, self cites included"
bysort cited: egen count_mindis`dis'_within15y_`num' = total(dummy_mindis`dis'_within15y_`num') if min_distance`num' ~= .
label variable count_mindis`dis'_within15y_`num' "no of cites within `dis' miles and 15 years, self cites included"
bysort cited: egen count_mindis`dis'_within10y_`num' = total(dummy_mindis`dis'_within10y_`num') if min_distance`num' ~= .
label variable count_mindis`dis'_within10y_`num' "no of cites within `dis' miles and 10 years, self cites included"
bysort cited: egen count_mindis`dis'_within5y_`num' = total(dummy_mindis`dis'_within5y_`num') if min_distance`num' ~= .
label variable count_mindis`dis'_within5y_`num' "no of cites within `dis' miles and 5 years, self cites included"
}
}
drop dummy_*

* Examiner cites within radius; all, within 5, 10 and 15 years
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
foreach num of numlist 1/18 {
gen d_exc_mindis`dis'_`num' = min_distance`num' < `dis' if min_distance`num' ~= . & examiner_cite == 1
gen d_exc_mindis`dis'_within15y_`num' = min_distance`num' < `dis' if min_distance`num' ~= . & examiner_cite == 1 & year_since_grant <= 15
gen d_exc_mindis`dis'_within10y_`num' = min_distance`num' < `dis' if min_distance`num' ~= . & examiner_cite == 1 & year_since_grant <= 10
gen d_exc_mindis`dis'_within5y_`num' = min_distance`num' < `dis' if min_distance`num' ~= . & examiner_cite == 1 & year_since_grant <= 5
}
}

foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
foreach num of numlist 1/18 {
bysort cited: egen count_exc_mindis`dis'_`num' = total(d_exc_mindis`dis'_`num') if min_distance`num' ~= .
label variable count_exc_mindis`dis'_`num' "no of examiner cites within `dis' miles"
bysort cited: egen count_exc_mindis`dis'_within15y_`num' = total(d_exc_mindis`dis'_within15y_`num') if min_distance`num' ~= .
label variable count_exc_mindis`dis'_within15y_`num' "no of examiner cites within `dis' miles and 15 years"
bysort cited: egen count_exc_mindis`dis'_within10y_`num' = total(d_exc_mindis`dis'_within10y_`num') if min_distance`num' ~= .
label variable count_exc_mindis`dis'_within10y_`num' "no of examiner cites within `dis' miles and 10 years"
bysort cited: egen count_exc_mindis`dis'_within5y_`num' = total(d_exc_mindis`dis'_within5y_`num') if min_distance`num' ~= .
label variable count_exc_mindis`dis'_within5y_`num' "no of examiner cites within `dis' miles and 5 years"
}
}
drop d_exc_*
************************************************************

************************************************************
* Variables
************************************************************
* Long distance sample (deceased and co-inventors living at least 500 miles apart)
egen help = rowmin(dist_*)  
gen dummy500 = 1 if help >= 500
replace dummy500 = 0 if dummy500 == .
label variable dummy500 "distance between deceased and all co-inventors at least 500 miles"
drop help 

* Number of cites
bysort cited: gen count_cites = _N
label variable count_cites "no of cites"
bysort cited: egen count_selfcites = total(self_cite)
label variable count_selfcites "no of self cites"
gen count_nsc = count_cites - count_selfcites
label variable count_nsc "no of cites without self cites"
************************************************************





************************************************************
* Descriptives
************************************************************
******************************
* Appendix A6
******************************
* Distributions of time to and distance of citations, for cited patent to citing patent
gen timespan = appl_date_citing - grant_date_cited
gen timespan_years = 5 if timespan <= 5*365
replace timespan_years = 10 if timespan > 5*365 & timespan <= 10*365
replace timespan_years = 15 if timespan > 10*365 & timespan <= 15*365
tab timespan_years if self_cite == 0, missing

foreach dis of numlist 10 20 25 30 40 50 60 70 75 80 90 100 110 120 130 140 150 {
foreach num of numlist 1/18 {
gen dummy_nsc_mindis`dis'_`num' = min_distance`num' <= `dis' if min_distance`num' ~= .
replace dummy_nsc_mindis`dis'_`num' = . if self_cite == 1
} 
}
egen min10_nsc = rowtotal(dummy_nsc_mindis10_1-dummy_nsc_mindis10_18)
replace min10_nsc = 1 if min10_nsc > 1 & min10_nsc < .
egen min20_nsc = rowtotal(dummy_nsc_mindis20_1-dummy_nsc_mindis20_18)
replace min20_nsc = 1 if min20_nsc > 1 & min20_nsc < .
egen min30_nsc = rowtotal(dummy_nsc_mindis30_1-dummy_nsc_mindis30_18)
replace min30_nsc = 1 if min30_nsc > 1 & min30_nsc < .
egen min40_nsc = rowtotal(dummy_nsc_mindis40_1-dummy_nsc_mindis40_18)
replace min40_nsc = 1 if min40_nsc > 1 & min40_nsc < .
egen min50_nsc = rowtotal(dummy_nsc_mindis50_1-dummy_nsc_mindis50_18)
replace min50_nsc = 1 if min50_nsc > 1 & min50_nsc < .
egen min60_nsc = rowtotal(dummy_nsc_mindis60_1-dummy_nsc_mindis60_18)
replace min60_nsc = 1 if min60_nsc > 1 & min60_nsc < .
egen min70_nsc = rowtotal(dummy_nsc_mindis70_1-dummy_nsc_mindis70_18)
replace min70_nsc = 1 if min70_nsc > 1 & min70_nsc < .
egen min80_nsc = rowtotal(dummy_nsc_mindis80_1-dummy_nsc_mindis80_18)
replace min80_nsc = 1 if min80_nsc > 1 & min80_nsc < .
egen min90_nsc = rowtotal(dummy_nsc_mindis90_1-dummy_nsc_mindis90_18)
replace min90_nsc = 1 if min90_nsc > 1 & min90_nsc < .
egen min100_nsc = rowtotal(dummy_nsc_mindis100_1-dummy_nsc_mindis100_18)
replace min100_nsc = 1 if min100_nsc > 1 & min100_nsc < .
egen min110_nsc = rowtotal(dummy_nsc_mindis110_1-dummy_nsc_mindis110_18)
replace min110_nsc = 1 if min110_nsc > 1 & min110_nsc < .
egen min120_nsc = rowtotal(dummy_nsc_mindis120_1-dummy_nsc_mindis120_18)
replace min120_nsc = 1 if min120_nsc > 1 & min120_nsc < .
egen min130_nsc = rowtotal(dummy_nsc_mindis130_1-dummy_nsc_mindis130_18)
replace min130_nsc = 1 if min130_nsc > 1 & min130_nsc < .
egen min140_nsc = rowtotal(dummy_nsc_mindis140_1-dummy_nsc_mindis140_18)
replace min140_nsc = 1 if min140_nsc > 1 & min140_nsc < .
egen min150_nsc = rowtotal(dummy_nsc_mindis150_1-dummy_nsc_mindis150_18)
replace min150_nsc = 1 if min150_nsc > 1 & min150_nsc < .
tab1 min10_nsc-min150_nsc
************************************************************





************************************************************
* Reshape data for analyses
************************************************************
keep cited appl_date_cited appl_year_cited grant_date_cited grant_year_cited age_* count_applications5_* dist_* inventor_id_cited* count_* dummy500 
duplicates drop
reshape long ///
	inventor_id_cited dist_ age_ count_applications5_ ///
	count_nsc_mindis10_ count_nsc_mindis20_ count_nsc_mindis30_ count_nsc_mindis40_ count_nsc_mindis50_ count_nsc_mindis60_ count_nsc_mindis70_ count_nsc_mindis80_ count_nsc_mindis90_ count_nsc_mindis100_ count_nsc_mindis110_ count_nsc_mindis120_ count_nsc_mindis130_ count_nsc_mindis140_ count_nsc_mindis150_ ///
	count_nsc_mindis10_within15y_ count_nsc_mindis20_within15y_ count_nsc_mindis30_within15y_ count_nsc_mindis40_within15y_ count_nsc_mindis50_within15y_ count_nsc_mindis60_within15y_ count_nsc_mindis70_within15y_ count_nsc_mindis80_within15y_ count_nsc_mindis90_within15y_ count_nsc_mindis100_within15y_ count_nsc_mindis110_within15y_ count_nsc_mindis120_within15y_ count_nsc_mindis130_within15y_ count_nsc_mindis140_within15y_ count_nsc_mindis150_within15y_ /// 
	count_nsc_mindis10_within10y_ count_nsc_mindis20_within10y_ count_nsc_mindis30_within10y_ count_nsc_mindis40_within10y_ count_nsc_mindis50_within10y_ count_nsc_mindis60_within10y_ count_nsc_mindis70_within10y_ count_nsc_mindis80_within10y_ count_nsc_mindis90_within10y_ count_nsc_mindis100_within10y_ count_nsc_mindis110_within10y_ count_nsc_mindis120_within10y_ count_nsc_mindis130_within10y_ count_nsc_mindis140_within10y_ count_nsc_mindis150_within10y_ ///
	count_nsc_mindis10_within5y_ count_nsc_mindis20_within5y_ count_nsc_mindis30_within5y_ count_nsc_mindis40_within5y_ count_nsc_mindis50_within5y_ count_nsc_mindis60_within5y_ count_nsc_mindis70_within5y_ count_nsc_mindis80_within5y_ count_nsc_mindis90_within5y_ count_nsc_mindis100_within5y_ count_nsc_mindis110_within5y_ count_nsc_mindis120_within5y_ count_nsc_mindis130_within5y_ count_nsc_mindis140_within5y_ count_nsc_mindis150_within5y_ ///
	count_nsc_mindis20_y1_ count_nsc_mindis20_y2_ count_nsc_mindis20_y3_ count_nsc_mindis20_y4_ count_nsc_mindis20_y5_ count_nsc_mindis20_y6_ count_nsc_mindis20_y7_ count_nsc_mindis20_y8_ count_nsc_mindis20_y9_ count_nsc_mindis20_y10_ ///
	count_mindis10_ count_mindis20_ count_mindis30_ count_mindis40_ count_mindis50_ count_mindis60_ count_mindis70_ count_mindis80_ count_mindis90_ count_mindis100_ count_mindis110_ count_mindis120_ count_mindis130_ count_mindis140_ count_mindis150_ ///
	count_mindis10_within15y_ count_mindis20_within15y_ count_mindis30_within15y_ count_mindis40_within15y_ count_mindis50_within15y_ count_mindis60_within15y_ count_mindis70_within15y_ count_mindis80_within15y_ count_mindis90_within15y_ count_mindis100_within15y_ count_mindis110_within15y_ count_mindis120_within15y_ count_mindis130_within15y_ count_mindis140_within15y_ count_mindis150_within15y_ /// 
	count_mindis10_within10y_ count_mindis20_within10y_ count_mindis30_within10y_ count_mindis40_within10y_ count_mindis50_within10y_ count_mindis60_within10y_ count_mindis70_within10y_ count_mindis80_within10y_ count_mindis90_within10y_ count_mindis100_within10y_ count_mindis110_within10y_ count_mindis120_within10y_ count_mindis130_within10y_ count_mindis140_within10y_ count_mindis150_within10y_ ///
	count_mindis10_within5y_ count_mindis20_within5y_ count_mindis30_within5y_ count_mindis40_within5y_ count_mindis50_within5y_ count_mindis60_within5y_ count_mindis70_within5y_ count_mindis80_within5y_ count_mindis90_within5y_ count_mindis100_within5y_ count_mindis110_within5y_ count_mindis120_within5y_ count_mindis130_within5y_ count_mindis140_within5y_ count_mindis150_within5y_ ///
	count_exc_mindis10_ count_exc_mindis20_ count_exc_mindis30_ count_exc_mindis40_ count_exc_mindis50_ count_exc_mindis60_ count_exc_mindis70_ count_exc_mindis80_ count_exc_mindis90_ count_exc_mindis100_ count_exc_mindis110_ count_exc_mindis120_ count_exc_mindis130_ count_exc_mindis140_ count_exc_mindis150_ ///
	count_exc_mindis10_within15y_ count_exc_mindis20_within15y_ count_exc_mindis30_within15y_ count_exc_mindis40_within15y_ count_exc_mindis50_within15y_ count_exc_mindis60_within15y_ count_exc_mindis70_within15y_ count_exc_mindis80_within15y_ count_exc_mindis90_within15y_ count_exc_mindis100_within15y_ count_exc_mindis110_within15y_ count_exc_mindis120_within15y_ count_exc_mindis130_within15y_ count_exc_mindis140_within15y_ count_exc_mindis150_within15y_ ///
	count_exc_mindis10_within10y_ count_exc_mindis20_within10y_ count_exc_mindis30_within10y_ count_exc_mindis40_within10y_ count_exc_mindis50_within10y_ count_exc_mindis60_within10y_ count_exc_mindis70_within10y_ count_exc_mindis80_within10y_ count_exc_mindis90_within10y_ count_exc_mindis100_within10y_ count_exc_mindis110_within10y_ count_exc_mindis120_within10y_ count_exc_mindis130_within10y_ count_exc_mindis140_within10y_ count_exc_mindis150_within10y_ ///
	count_exc_mindis10_within5y_ count_exc_mindis20_within5y_ count_exc_mindis30_within5y_ count_exc_mindis40_within5y_ count_exc_mindis50_within5y_ count_exc_mindis60_within5y_ count_exc_mindis70_within5y_ count_exc_mindis80_within5y_ count_exc_mindis90_within5y_ count_exc_mindis100_within5y_ count_exc_mindis110_within5y_ count_exc_mindis120_within5y_ count_exc_mindis130_within5y_ count_exc_mindis140_within5y_ count_exc_mindis150_within5y_ ///
	, i(cited) j(seq_id)
drop if inventor_id_cited == ""
************************************************************





************************************************************
* Variables
************************************************************
* Deceased
gen deceased = 0
replace deceased = 1 if seq_id == 1

* Number of inventors
bysort cited: gen count_inv = _N
label variable count_inv "number of inventors"

* Premature death
gen age_restriction = 1
replace age_restriction = 0 if age_ < 10 // drop all inventors under 10
replace age_restriction = 0 if age_ == . // drop all missings
replace age_restriction = 0 if age_ > 60 & deceased == 1 // drop all deceased inventors over 60
gen help = 1 if age_ > 60 & deceased == 1 
bysort cited: egen help2 = total(help)
replace age_restriction = 0 if help2 == 1 // drop patent if deceased is over 60
drop help help2
gen help = 1 if age_restriction == 1
bysort cited: egen help2 = total(help)
replace age_restriction = 0 if help2 == 1 // drop if patent has no co-inventor with known age 
drop help help2

gen age_restriction2 = 0
replace age_restriction2 = 1 if age_ > 60 & age_ < . & deceased == 1 // keep all deceased inventors over 60
bysort cited: egen help = total(age_restriction2)
replace age_restriction2 = 1 if help == 1 // keep patent if deceased is over 60
drop help 
gen help = 1 if age_restriction == 1
bysort cited: egen help2 = total(help)
replace age_restriction = 0 if help2 == 1 // drop if patent has no co-inventor with known age 
drop help help2
************************************************************





************************************************************
* Descriptives
************************************************************
* Number of observations
quietly display
display "number of observations: " r(N)

* Number of patents
egen no_patents = nvals(cited)
display "number of patents: " no_patents 

******************************
* Table 1 + Appendix A7
******************************
* Descriptive statistics of geographic distances of citations
sum count_nsc_mindis??_, d // all
sum count_nsc_mindis???_, d // all
sum count_nsc_mindis*_within15y_, d // within 15 years
sum count_nsc_mindis*_within10y_, d // within 10 years
sum count_nsc_mindis*_within5y_, d // within 5 years
* Share of 0 cites
tab1 count_nsc_mindis??_ // all
tab1 count_nsc_mindis???_ // all
tab1 count_nsc_mindis*_within15y_ // within 15 years
tab1 count_nsc_mindis*_within10y_ // within 10 years
tab1 count_nsc_mindis*_within5y_ // within 5 years
* Share of patents with 0 cites
foreach num of numlist 10(10)150 {
bysort cited: egen help`num' = total(count_nsc_mindis`num'_)
replace help`num' = 1 if help`num' > 0
bysort cited: egen help`num'_within15y = total(count_nsc_mindis`num'_within15y_)
replace help`num'_within15y = 1 if help`num'_within15y > 0
bysort cited: egen help`num'_within10y = total(count_nsc_mindis`num'_within10y_)
replace help`num'_within10y = 1 if help`num'_within10y > 0
bysort cited: egen help`num'_within5y = total(count_nsc_mindis`num'_within5y_)
replace help`num'_within5y = 1 if help`num'_within5y > 0
}
tab1 help?? if deceased == 1 // all
tab1 help??? if deceased == 1 // all
tab1 help*_within15y if deceased == 1 // within 15 years
tab1 help*_within10y if deceased == 1 // within 10 years
tab1 help*_within5y if deceased == 1 // within 5 years
drop help*

******************************
* Appendix A2
******************************
* Distribution of number of inventors per patent
tab count_inv if deceased == 1 
******************************

******************************
* Appendix A3
******************************
* Distribution of dinstances from deceased and living co-inventors
gen distance_inventors = 10 if dist_ <= 10
replace distance_inventors = 50 if dist_ > 10 & dist_ <= 50
replace distance_inventors = 100 if dist_ > 50 & dist_ <= 100
replace distance_inventors = 300 if dist_ > 100 & dist_ <= 300
replace distance_inventors = 500 if dist_ > 300 & dist_ <= 500
replace distance_inventors = 1000 if dist_ > 500 & dist_ <= 1000
replace distance_inventors = 3262 if dist_ > 1000 & dist_ <= 3262
tab distance_inventors
******************************

******************************
* Appendix A4
******************************
* Distribution of application years of patents
tab appl_year if deceased == 1
******************************

******************************
* Appendix A5
******************************
* Distribution of grant years of patents
tab grant_year if deceased == 1
******************************

******************************
* Appendix A8
******************************
* Comparison of deceased and living co-inventors
sum age_, d
sum age_ if deceased == 1, d
sum age_ if deceased == 0, d
sum age_ if age_restriction == 1, d
sum age_ if deceased == 1 & age_restriction == 1, d
sum age_ if deceased == 0 & age_restriction == 1, d
sum count_applications5, d
sum count_applications5 if deceased == 1, d
sum count_applications5 if deceased == 0, d
sum count_applications5 if age_restriction == 1, d
sum count_applications5 if deceased == 1 & age_restriction == 1, d
sum count_applications5 if deceased == 0 & age_restriction == 1, d
ttest age_ if age_restriction == 1, by(deceased)
ttest count_applications5 if age_restriction == 1, by(deceased)
******************************

******************************
* Appendix A9
******************************
* Prediction of death based on inventor age and prior patenting activity
probit deceased age_ count_applications5, cluster(cited)
probit deceased age_ count_applications5 if age_restriction == 1, cluster(cited)
******************************

************************************************************





************************************************************
* Analyses
************************************************************

******************************
* Tabel 2, Panel A + Appendix A11
******************************
* Knowledge flow reduction across distance and time: analysis sample
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
ppmlhdfe count_nsc_mindis`dis'_ deceased, absorb(cited) cluster(cited)
estimates store basic_poisson_`dis'
}
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
ppmlhdfe count_nsc_mindis`dis'_within15y_ deceased, absorb(cited) cluster(cited)
estimates store basic_poisson_`dis'_15y
}
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
ppmlhdfe count_nsc_mindis`dis'_within10y_ deceased, absorb(cited) cluster(cited)
estimates store basic_poisson_`dis'_10y
}
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
ppmlhdfe count_nsc_mindis`dis'_within5y_ deceased, absorb(cited) cluster(cited)
estimates store basic_poisson_`dis'_5y
}
esttab basic_poisson_10 basic_poisson_20 basic_poisson_30 basic_poisson_40 basic_poisson_50 basic_poisson_60 basic_poisson_70 basic_poisson_80 basic_poisson_90 basic_poisson_100 basic_poisson_110 basic_poisson_120 basic_poisson_130 basic_poisson_140 basic_poisson_150, star(* 0.1 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) stats(N r2_p) 
esttab basic_poisson_10_15y basic_poisson_20_15y basic_poisson_30_15y basic_poisson_40_15y basic_poisson_50_15y basic_poisson_60_15y basic_poisson_70_15y basic_poisson_80_15y basic_poisson_90_15y basic_poisson_100_15y basic_poisson_110_15y basic_poisson_120_15y basic_poisson_130_15y basic_poisson_140_15y basic_poisson_150_15y, star(* 0.1 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) stats(N r2_p) 
esttab basic_poisson_10_10y basic_poisson_20_10y basic_poisson_30_10y basic_poisson_40_10y basic_poisson_50_10y basic_poisson_60_10y basic_poisson_70_10y basic_poisson_80_10y basic_poisson_90_10y basic_poisson_100_10y basic_poisson_110_10y basic_poisson_120_10y basic_poisson_130_10y basic_poisson_140_10y basic_poisson_150_10y, star(* 0.1 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) stats(N r2_p) 
esttab basic_poisson_10_5y basic_poisson_20_5y basic_poisson_30_5y basic_poisson_40_5y basic_poisson_50_5y basic_poisson_60_5y basic_poisson_70_5y basic_poisson_80_5y basic_poisson_90_5y basic_poisson_100_5y basic_poisson_110_5y basic_poisson_120_5y basic_poisson_130_5y basic_poisson_140_5y basic_poisson_150_5y, star(* 0.1 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) stats(N r2_p) 
estimates clear
******************************

******************************
* Tabel 2, Panel B + Appendix A12
******************************
* Knowledge flow reduction across distance and time: premature death sample
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
ppmlhdfe count_nsc_mindis`dis'_ deceased if age_restriction == 1, absorb(cited) cluster(cited)
estimates store basic_poisson_`dis'_age60
}
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
ppmlhdfe count_nsc_mindis`dis'_within15y_ deceased if age_restriction == 1, absorb(cited) cluster(cited)
estimates store basic_poisson_`dis'_15y_age60
}
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
ppmlhdfe count_nsc_mindis`dis'_within10y_ deceased if age_restriction == 1, absorb(cited) cluster(cited)
estimates store basic_poisson_`dis'_10y_age60
}
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
ppmlhdfe count_nsc_mindis`dis'_within5y_ deceased if age_restriction == 1, absorb(cited) cluster(cited)
estimates store basic_poisson_`dis'_5y_age60
}
esttab basic_poisson_10_age60 basic_poisson_20_age60 basic_poisson_30_age60 basic_poisson_40_age60 basic_poisson_50_age60 basic_poisson_60_age60 basic_poisson_70_age60 basic_poisson_80_age60 basic_poisson_90_age60 basic_poisson_100_age60 basic_poisson_110_age60 basic_poisson_120_age60 basic_poisson_130_age60 basic_poisson_140_age60 basic_poisson_150_age60, star(* 0.1 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) stats(N r2_p) 
esttab basic_poisson_10_15y_age60 basic_poisson_20_15y_age60 basic_poisson_30_15y_age60 basic_poisson_40_15y_age60 basic_poisson_50_15y_age60 basic_poisson_60_15y_age60 basic_poisson_70_15y_age60 basic_poisson_80_15y_age60 basic_poisson_90_15y_age60 basic_poisson_100_15y_age60 basic_poisson_110_15y_age60 basic_poisson_120_15y_age60 basic_poisson_130_15y_age60 basic_poisson_140_15y_age60 basic_poisson_150_15y_age60, star(* 0.1 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) stats(N r2_p) 
esttab basic_poisson_10_10y_age60 basic_poisson_20_10y_age60 basic_poisson_30_10y_age60 basic_poisson_40_10y_age60 basic_poisson_50_10y_age60 basic_poisson_60_10y_age60 basic_poisson_70_10y_age60 basic_poisson_80_10y_age60 basic_poisson_90_10y_age60 basic_poisson_100_10y_age60 basic_poisson_110_10y_age60 basic_poisson_120_10y_age60 basic_poisson_130_10y_age60 basic_poisson_140_10y_age60 basic_poisson_150_10y_age60, star(* 0.1 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) stats(N r2_p) 
esttab basic_poisson_10_5y_age60 basic_poisson_20_5y_age60 basic_poisson_30_5y_age60 basic_poisson_40_5y_age60 basic_poisson_50_5y_age60 basic_poisson_60_5y_age60 basic_poisson_70_5y_age60 basic_poisson_80_5y_age60 basic_poisson_90_5y_age60 basic_poisson_100_5y_age60 basic_poisson_110_5y_age60 basic_poisson_120_5y_age60 basic_poisson_130_5y_age60 basic_poisson_140_5y_age60 basic_poisson_150_5y_age60, star(* 0.1 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) stats(N r2_p) 
estimates clear
******************************

******************************
* Tabel 2, Panel C + Appendix A13
******************************
* Knowledge flow reduction across distance and time: large distance sample
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
ppmlhdfe count_nsc_mindis`dis'_ deceased if dummy500 == 1, absorb(cited) cluster(cited)
estimates store poisson500m1_`dis'_1p
}
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
ppmlhdfe count_nsc_mindis`dis'_within15y_ deceased if dummy500 == 1, absorb(cited) cluster(cited)
estimates store poisson500m1_`dis'_15y_1p
}
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
ppmlhdfe count_nsc_mindis`dis'_within10y_ deceased if dummy500 == 1, absorb(cited) cluster(cited)
estimates store poisson500m1_`dis'_10y_1p
}
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
ppmlhdfe count_nsc_mindis`dis'_within5y_ deceased if dummy500 == 1, absorb(cited) cluster(cited)
estimates store poisson500m1_`dis'_5y_1p
}
esttab poisson500m1_10_1p poisson500m1_20_1p poisson500m1_30_1p poisson500m1_40_1p poisson500m1_50_1p poisson500m1_60_1p poisson500m1_70_1p poisson500m1_80_1p poisson500m1_90_1p poisson500m1_100_1p poisson500m1_110_1p poisson500m1_120_1p poisson500m1_130_1p poisson500m1_140_1p poisson500m1_150_1p, star(* 0.1 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) stats(N r2_p) 
esttab poisson500m1_10_15y_1p poisson500m1_20_15y_1p poisson500m1_30_15y_1p poisson500m1_40_15y_1p poisson500m1_50_15y_1p poisson500m1_60_15y_1p poisson500m1_70_15y_1p poisson500m1_80_15y_1p poisson500m1_90_15y_1p poisson500m1_100_15y_1p poisson500m1_110_15y_1p poisson500m1_120_15y_1p poisson500m1_130_15y_1p poisson500m1_140_15y_1p poisson500m1_150_15y_1p, star(* 0.1 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) stats(N r2_p) 
esttab poisson500m1_10_10y_1p poisson500m1_20_10y_1p poisson500m1_30_10y_1p poisson500m1_40_10y_1p poisson500m1_50_10y_1p poisson500m1_60_10y_1p poisson500m1_70_10y_1p poisson500m1_80_10y_1p poisson500m1_90_10y_1p poisson500m1_100_10y_1p poisson500m1_110_10y_1p poisson500m1_120_10y_1p poisson500m1_130_10y_1p poisson500m1_140_10y_1p poisson500m1_150_10y_1p, star(* 0.1 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) stats(N r2_p) 
esttab poisson500m1_10_5y_1p poisson500m1_20_5y_1p poisson500m1_30_5y_1p poisson500m1_40_5y_1p poisson500m1_50_5y_1p poisson500m1_60_5y_1p poisson500m1_70_5y_1p poisson500m1_80_5y_1p poisson500m1_90_5y_1p poisson500m1_100_5y_1p poisson500m1_110_5y_1p poisson500m1_120_5y_1p poisson500m1_130_5y_1p poisson500m1_140_5y_1p poisson500m1_150_5y_1p, star(* 0.1 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) stats(N r2_p) 
estimates clear
******************************

******************************
* Appendix A17
******************************
* Knowledge flow reduction within 20 miles over time
foreach year of numlist 1/10 {
ppmlhdfe count_nsc_mindis20_y`year'_ deceased, absorb(cited) cluster(cited) 
estimates store poisson_20miles_y`year'
}
esttab poisson_20miles_y1 poisson_20miles_y2 poisson_20miles_y3 poisson_20miles_y4 poisson_20miles_y5 poisson_20miles_y6 poisson_20miles_y7 poisson_20miles_y8 poisson_20miles_y9 poisson_20miles_y10, star(* 0.1 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) stats(N r2_p) 
estimates clear
******************************

******************************
* Appendix A18
******************************
* Knowledge flow reduction across distance and time: full sample without top 1% most cited patents
bysort cited: gen help = _n
sum count_nsc if help == 1, d
gen dummy1p = count_nsc >= `r(p99)'
label variable dummy1p "top 1% most cited patents"
drop help
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
ppmlhdfe count_nsc_mindis`dis'_ deceased if dummy1p == 0, absorb(cited) cluster(cited)
estimates store basic_poisson_`dis'_1p
}
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
ppmlhdfe count_nsc_mindis`dis'_within15y_ deceased if dummy1p == 0, absorb(cited) cluster(cited)
estimates store basic_poisson_`dis'_15y_1p
}
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
ppmlhdfe count_nsc_mindis`dis'_within10y_ deceased if dummy1p == 0, absorb(cited) cluster(cited)
estimates store basic_poisson_`dis'_10y_1p
}
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
ppmlhdfe count_nsc_mindis`dis'_within5y_ deceased if dummy1p == 0, absorb(cited) cluster(cited)
estimates store basic_poisson_`dis'_5y_1p
}
esttab basic_poisson_10_1p basic_poisson_20_1p basic_poisson_30_1p basic_poisson_40_1p basic_poisson_50_1p basic_poisson_60_1p basic_poisson_70_1p basic_poisson_80_1p basic_poisson_90_1p basic_poisson_100_1p basic_poisson_110_1p basic_poisson_120_1p basic_poisson_130_1p basic_poisson_140_1p basic_poisson_150_1p, star(* 0.1 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) stats(N r2_p) 
esttab basic_poisson_10_15y_1p basic_poisson_20_15y_1p basic_poisson_30_15y_1p basic_poisson_40_15y_1p basic_poisson_50_15y_1p basic_poisson_60_15y_1p basic_poisson_70_15y_1p basic_poisson_80_15y_1p basic_poisson_90_15y_1p basic_poisson_100_15y_1p basic_poisson_110_15y_1p basic_poisson_120_15y_1p basic_poisson_130_15y_1p basic_poisson_140_15y_1p basic_poisson_150_15y_1p, star(* 0.1 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) stats(N r2_p) 
esttab basic_poisson_10_10y_1p basic_poisson_20_10y_1p basic_poisson_30_10y_1p basic_poisson_40_10y_1p basic_poisson_50_10y_1p basic_poisson_60_10y_1p basic_poisson_70_10y_1p basic_poisson_80_10y_1p basic_poisson_90_10y_1p basic_poisson_100_10y_1p basic_poisson_110_10y_1p basic_poisson_120_10y_1p basic_poisson_130_10y_1p basic_poisson_140_10y_1p basic_poisson_150_10y_1p, star(* 0.1 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) stats(N r2_p) 
esttab basic_poisson_10_5y_1p basic_poisson_20_5y_1p basic_poisson_30_5y_1p basic_poisson_40_5y_1p basic_poisson_50_5y_1p basic_poisson_60_5y_1p basic_poisson_70_5y_1p basic_poisson_80_5y_1p basic_poisson_90_5y_1p basic_poisson_100_5y_1p basic_poisson_110_5y_1p basic_poisson_120_5y_1p basic_poisson_130_5y_1p basic_poisson_140_5y_1p basic_poisson_150_5y_1p, star(* 0.1 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) stats(N r2_p) 
estimates clear
******************************

******************************
* Appendix A19
******************************
* Linear probability model
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
gen d_count_nsc_mindis`dis'_within5y_ = count_nsc_mindis`dis'_within5y_ > 0
gen d_count_nsc_mindis`dis'_within10y_ = count_nsc_mindis`dis'_within10y_ > 0
gen d_count_nsc_mindis`dis'_within15y_ = count_nsc_mindis`dis'_within15y_ > 0
gen d_count_nsc_mindis`dis'_ = count_nsc_mindis`dis'_ > 0
}
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
reghdfe d_count_nsc_mindis`dis'_ deceased, absorb(cited) cluster(cited)
estimates store basic_linprob_`dis'
}
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
reghdfe d_count_nsc_mindis`dis'_within15y_ deceased, absorb(cited) cluster(cited)
estimates store basic_linprob_`dis'_15y
}
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
reghdfe d_count_nsc_mindis`dis'_within10y_ deceased, absorb(cited) cluster(cited)
estimates store basic_linprob_`dis'_10y
}
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
reghdfe d_count_nsc_mindis`dis'_within5y_ deceased, absorb(cited) cluster(cited)
estimates store basic_linprob_`dis'_5y
}
esttab basic_linprob_10 basic_linprob_20 basic_linprob_30 basic_linprob_40 basic_linprob_50 basic_linprob_60 basic_linprob_70 basic_linprob_80 basic_linprob_90 basic_linprob_100 basic_linprob_110 basic_linprob_120 basic_linprob_130 basic_linprob_140 basic_linprob_150, star(* 0.1 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) stats(N r2 r2_a) 
esttab basic_linprob_10_15y basic_linprob_20_15y basic_linprob_30_15y basic_linprob_40_15y basic_linprob_50_15y basic_linprob_60_15y basic_linprob_70_15y basic_linprob_80_15y basic_linprob_90_15y basic_linprob_100_15y basic_linprob_110_15y basic_linprob_120_15y basic_linprob_130_15y basic_linprob_140_15y basic_linprob_150_15y, star(* 0.1 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) stats(N r2 r2_a) 
esttab basic_linprob_10_10y basic_linprob_20_10y basic_linprob_30_10y basic_linprob_40_10y basic_linprob_50_10y basic_linprob_60_10y basic_linprob_70_10y basic_linprob_80_10y basic_linprob_90_10y basic_linprob_100_10y basic_linprob_110_10y basic_linprob_120_10y basic_linprob_130_10y basic_linprob_140_10y basic_linprob_150_10y, star(* 0.1 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) stats(N r2 r2_a) 
esttab basic_linprob_10_5y basic_linprob_20_5y basic_linprob_30_5y basic_linprob_40_5y basic_linprob_50_5y basic_linprob_60_5y basic_linprob_70_5y basic_linprob_80_5y basic_linprob_90_5y basic_linprob_100_5y basic_linprob_110_5y basic_linprob_120_5y basic_linprob_130_5y basic_linprob_140_5y basic_linprob_150_5y, star(* 0.1 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) stats(N r2 r2_a) 
estimates clear
******************************

******************************
* Appendix A20
******************************
* OLS
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
gen lncount_nsc_mindis`dis'_within5y_ = ln(count_nsc_mindis`dis'_within5y_ + 1)
gen lncount_nsc_mindis`dis'_within10y_ = ln(count_nsc_mindis`dis'_within10y_ + 1)
gen lncount_nsc_mindis`dis'_within15y_ = ln(count_nsc_mindis`dis'_within15y_ + 1)
gen lncount_nsc_mindis`dis'_ = ln(count_nsc_mindis`dis'_ + 1)
}
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
reghdfe lncount_nsc_mindis`dis'_ deceased, absorb(cited) cluster(cited)
estimates store basic_lin_`dis'
}
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
reghdfe lncount_nsc_mindis`dis'_within15y_ deceased, absorb(cited) cluster(cited)
estimates store basic_lin_`dis'_15y
}
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
reghdfe lncount_nsc_mindis`dis'_within10y_ deceased, absorb(cited) cluster(cited)
estimates store basic_lin_`dis'_10y
}
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
reghdfe lncount_nsc_mindis`dis'_within5y_ deceased, absorb(cited) cluster(cited)
estimates store basic_lin_`dis'_5y
}
esttab basic_lin_10 basic_lin_20 basic_lin_30 basic_lin_40 basic_lin_50 basic_lin_60 basic_lin_70 basic_lin_80 basic_lin_90 basic_lin_100 basic_lin_110 basic_lin_120 basic_lin_130 basic_lin_140 basic_lin_150, star(* 0.1 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) stats(N r2 r2_a) 
esttab basic_lin_10_15y basic_lin_20_15y basic_lin_30_15y basic_lin_40_15y basic_lin_50_15y basic_lin_60_15y basic_lin_70_15y basic_lin_80_15y basic_lin_90_15y basic_lin_100_15y basic_lin_110_15y basic_lin_120_15y basic_lin_130_15y basic_lin_140_15y basic_lin_150_15y, star(* 0.1 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) stats(N r2 r2_a) 
esttab basic_lin_10_10y basic_lin_20_10y basic_lin_30_10y basic_lin_40_10y basic_lin_50_10y basic_lin_60_10y basic_lin_70_10y basic_lin_80_10y basic_lin_90_10y basic_lin_100_10y basic_lin_110_10y basic_lin_120_10y basic_lin_130_10y basic_lin_140_10y basic_lin_150_10y, star(* 0.1 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) stats(N r2 r2_a) 
esttab basic_lin_10_5y basic_lin_20_5y basic_lin_30_5y basic_lin_40_5y basic_lin_50_5y basic_lin_60_5y basic_lin_70_5y basic_lin_80_5y basic_lin_90_5y basic_lin_100_5y basic_lin_110_5y basic_lin_120_5y basic_lin_130_5y basic_lin_140_5y basic_lin_150_5y, star(* 0.1 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) stats(N r2 r2_a) 
estimates clear
******************************

******************************
* Appendix A21
******************************
* Self citations
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
ppmlhdfe count_mindis`dis'_ deceased, absorb(cited) cluster(cited)
estimates store basic_poisson_sc_`dis'
}
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
ppmlhdfe count_mindis`dis'_within15y_ deceased, absorb(cited) cluster(cited)
estimates store basic_poisson_sc_`dis'_15y
}
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
ppmlhdfe count_mindis`dis'_within10y_ deceased, absorb(cited) cluster(cited)
estimates store basic_poisson_sc_`dis'_10y
}
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
ppmlhdfe count_mindis`dis'_within5y_ deceased, absorb(cited) cluster(cited)
estimates store basic_poisson_sc_`dis'_5y
}
esttab basic_poisson_sc_10 basic_poisson_sc_20 basic_poisson_sc_30 basic_poisson_sc_40 basic_poisson_sc_50 basic_poisson_sc_60 basic_poisson_sc_70 basic_poisson_sc_80 basic_poisson_sc_90 basic_poisson_sc_100 basic_poisson_sc_110 basic_poisson_sc_120 basic_poisson_sc_130 basic_poisson_sc_140 basic_poisson_sc_150, star(* 0.1 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) stats(N r2_p) 
esttab basic_poisson_sc_10_15y basic_poisson_sc_20_15y basic_poisson_sc_30_15y basic_poisson_sc_40_15y basic_poisson_sc_50_15y basic_poisson_sc_60_15y basic_poisson_sc_70_15y basic_poisson_sc_80_15y basic_poisson_sc_90_15y basic_poisson_sc_100_15y basic_poisson_sc_110_15y basic_poisson_sc_120_15y basic_poisson_sc_130_15y basic_poisson_sc_140_15y basic_poisson_sc_150_15y, star(* 0.1 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) stats(N r2_p) 
esttab basic_poisson_sc_10_10y basic_poisson_sc_20_10y basic_poisson_sc_30_10y basic_poisson_sc_40_10y basic_poisson_sc_50_10y basic_poisson_sc_60_10y basic_poisson_sc_70_10y basic_poisson_sc_80_10y basic_poisson_sc_90_10y basic_poisson_sc_100_10y basic_poisson_sc_110_10y basic_poisson_sc_120_10y basic_poisson_sc_130_10y basic_poisson_sc_140_10y basic_poisson_sc_150_10y, star(* 0.1 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) stats(N r2_p) 
esttab basic_poisson_sc_10_5y basic_poisson_sc_20_5y basic_poisson_sc_30_5y basic_poisson_sc_40_5y basic_poisson_sc_50_5y basic_poisson_sc_60_5y basic_poisson_sc_70_5y basic_poisson_sc_80_5y basic_poisson_sc_90_5y basic_poisson_sc_100_5y basic_poisson_sc_110_5y basic_poisson_sc_120_5y basic_poisson_sc_130_5y basic_poisson_sc_140_5y basic_poisson_sc_150_5y, star(* 0.1 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) stats(N r2_p) 
estimates clear
******************************

******************************
* Appendix A22
******************************
* Examiner cites
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
ppmlhdfe count_exc_mindis`dis'_ deceased, absorb(cited) cluster(cited)
estimates store examiner_poisson_`dis'
}
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
ppmlhdfe count_exc_mindis`dis'_within15y_ deceased, absorb(cited) cluster(cited)
estimates store examiner_poisson_`dis'_15y
}
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
ppmlhdfe count_exc_mindis`dis'_within10y_ deceased, absorb(cited) cluster(cited)
estimates store examiner_poisson_`dis'_10y
}
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
ppmlhdfe count_exc_mindis`dis'_within5y_ deceased, absorb(cited) cluster(cited)
estimates store examiner_poisson_`dis'_5y
}
esttab examiner_poisson_10 examiner_poisson_20 examiner_poisson_30 examiner_poisson_40 examiner_poisson_50 examiner_poisson_60 examiner_poisson_70 examiner_poisson_80 examiner_poisson_90 examiner_poisson_100 examiner_poisson_110 examiner_poisson_120 examiner_poisson_130 examiner_poisson_140 examiner_poisson_150, star(* 0.1 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) stats(N r2_p) 
esttab examiner_poisson_10_15y examiner_poisson_20_15y examiner_poisson_30_15y examiner_poisson_40_15y examiner_poisson_50_15y examiner_poisson_60_15y examiner_poisson_70_15y examiner_poisson_80_15y examiner_poisson_90_15y examiner_poisson_100_15y examiner_poisson_110_15y examiner_poisson_120_15y examiner_poisson_130_15y examiner_poisson_140_15y examiner_poisson_150_15y, star(* 0.1 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) stats(N r2_p) 
esttab examiner_poisson_10_10y examiner_poisson_20_10y examiner_poisson_30_10y examiner_poisson_40_10y examiner_poisson_50_10y examiner_poisson_60_10y examiner_poisson_70_10y examiner_poisson_80_10y examiner_poisson_90_10y examiner_poisson_100_10y examiner_poisson_110_10y examiner_poisson_120_10y examiner_poisson_130_10y examiner_poisson_140_10y examiner_poisson_150_10y, star(* 0.1 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) stats(N r2_p) 
esttab examiner_poisson_10_5y examiner_poisson_20_5y examiner_poisson_30_5y examiner_poisson_40_5y examiner_poisson_50_5y examiner_poisson_60_5y examiner_poisson_70_5y examiner_poisson_80_5y examiner_poisson_90_5y examiner_poisson_100_5y examiner_poisson_110_5y examiner_poisson_120_5y examiner_poisson_130_5y examiner_poisson_140_5y examiner_poisson_150_5y, star(* 0.1 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) stats(N r2_p) 
estimates clear
******************************

******************************
* Appendix A23
******************************
* Observations weighted by 1/(number of inventors)
gen weight = count_inv
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
ppmlhdfe count_nsc_mindis`dis'_ deceased [fweight=weight], absorb(cited) cluster(cited)
estimates store weight_poisson_`dis'
}
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
ppmlhdfe count_nsc_mindis`dis'_within15y_ deceased [fweight=weight], absorb(cited) cluster(cited)
estimates store weight_poisson_`dis'_15y
}
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
ppmlhdfe count_nsc_mindis`dis'_within10y_ deceased [fweight=weight], absorb(cited) cluster(cited)
estimates store weight_poisson_`dis'_10y
}
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
ppmlhdfe count_nsc_mindis`dis'_within5y_ deceased [fweight=weight], absorb(cited) cluster(cited) 
estimates store weight_poisson_`dis'_5y
}
esttab weight_poisson_10 weight_poisson_20 weight_poisson_30 weight_poisson_40 weight_poisson_50 weight_poisson_60 weight_poisson_70 weight_poisson_80 weight_poisson_90 weight_poisson_100 weight_poisson_110 weight_poisson_120 weight_poisson_130 weight_poisson_140 weight_poisson_150, star(* 0.1 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) stats(N r2_p) 
esttab weight_poisson_10_15y weight_poisson_20_15y weight_poisson_30_15y weight_poisson_40_15y weight_poisson_50_15y weight_poisson_60_15y weight_poisson_70_15y weight_poisson_80_15y weight_poisson_90_15y weight_poisson_100_15y weight_poisson_110_15y weight_poisson_120_15y weight_poisson_130_15y weight_poisson_140_15y weight_poisson_150_15y, star(* 0.1 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) stats(N r2_p) 
esttab weight_poisson_10_10y weight_poisson_20_10y weight_poisson_30_10y weight_poisson_40_10y weight_poisson_50_10y weight_poisson_60_10y weight_poisson_70_10y weight_poisson_80_10y weight_poisson_90_10y weight_poisson_100_10y weight_poisson_110_10y weight_poisson_120_10y weight_poisson_130_10y weight_poisson_140_10y weight_poisson_150_10y, star(* 0.1 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) stats(N r2_p) 
esttab weight_poisson_10_5y weight_poisson_20_5y weight_poisson_30_5y weight_poisson_40_5y weight_poisson_50_5y weight_poisson_60_5y weight_poisson_70_5y weight_poisson_80_5y weight_poisson_90_5y weight_poisson_100_5y weight_poisson_110_5y weight_poisson_120_5y weight_poisson_130_5y weight_poisson_140_5y weight_poisson_150_5y, star(* 0.1 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) stats(N r2_p) 
estimates clear
******************************

******************************
* Appendix A24
******************************
* At least one co-inventor lives closer than 500 miles
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
ppmlhdfe count_nsc_mindis`dis'_ deceased if dummy500 == 0, absorb(cited) cluster(cited)
estimates store poisson500m0_`dis'
}
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
ppmlhdfe count_nsc_mindis`dis'_within15y_ deceased if dummy500 == 0, absorb(cited) cluster(cited)
estimates store poisson500m0_`dis'_15y
}
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
ppmlhdfe count_nsc_mindis`dis'_within10y_ deceased if dummy500 == 0, absorb(cited) cluster(cited)
estimates store poisson500m0_`dis'_10y
}
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
ppmlhdfe count_nsc_mindis`dis'_within5y_ deceased if dummy500 == 0, absorb(cited) cluster(cited)
estimates store poisson500m0_`dis'_5y
}
esttab poisson500m0_10 poisson500m0_20 poisson500m0_30 poisson500m0_40 poisson500m0_50 poisson500m0_60 poisson500m0_70 poisson500m0_80 poisson500m0_90 poisson500m0_100 poisson500m0_110 poisson500m0_120 poisson500m0_130 poisson500m0_140 poisson500m0_150, star(* 0.1 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) stats(N r2_p) 
esttab poisson500m0_10_15y poisson500m0_20_15y poisson500m0_30_15y poisson500m0_40_15y poisson500m0_50_15y poisson500m0_60_15y poisson500m0_70_15y poisson500m0_80_15y poisson500m0_90_15y poisson500m0_100_15y poisson500m0_110_15y poisson500m0_120_15y poisson500m0_130_15y poisson500m0_140_15y poisson500m0_150_15y, star(* 0.1 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) stats(N r2_p) 
esttab poisson500m0_10_10y poisson500m0_20_10y poisson500m0_30_10y poisson500m0_40_10y poisson500m0_50_10y poisson500m0_60_10y poisson500m0_70_10y poisson500m0_80_10y poisson500m0_90_10y poisson500m0_100_10y poisson500m0_110_10y poisson500m0_120_10y poisson500m0_130_10y poisson500m0_140_10y poisson500m0_150_10y, star(* 0.1 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) stats(N r2_p) 
esttab poisson500m0_10_5y poisson500m0_20_5y poisson500m0_30_5y poisson500m0_40_5y poisson500m0_50_5y poisson500m0_60_5y poisson500m0_70_5y poisson500m0_80_5y poisson500m0_90_5y poisson500m0_100_5y poisson500m0_110_5y poisson500m0_120_5y poisson500m0_130_5y poisson500m0_140_5y poisson500m0_150_5y, star(* 0.1 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) stats(N r2_p) 
estimates clear
******************************

******************************
* Appendix A25
******************************
* Knowledge flow reduction across distance and time: CEM sample
* cem
merge 1:1 cited inventor_id_cited using "C:\replication\data\cem.dta", nogen

foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
ppmlhdfe count_nsc_mindis`dis'_ deceased if cem_ == 1, absorb(cited) cluster(cited)
estimates store cem_poisson_`dis'
}
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
ppmlhdfe count_nsc_mindis`dis'_within15y_ deceased if cem_ == 1, absorb(cited) cluster(cited)
estimates store cem_poisson_`dis'_15y
}
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
ppmlhdfe count_nsc_mindis`dis'_within10y_ deceased if cem_ == 1, absorb(cited) cluster(cited)
estimates store cem_poisson_`dis'_10y
}
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
ppmlhdfe count_nsc_mindis`dis'_within5y_ deceased if cem_ == 1, absorb(cited) cluster(cited)
estimates store cem_poisson_`dis'_5y
}
esttab cem_poisson_10 cem_poisson_20 cem_poisson_30 cem_poisson_40 cem_poisson_50 cem_poisson_60 cem_poisson_70 cem_poisson_80 cem_poisson_90 cem_poisson_100 cem_poisson_110 cem_poisson_120 cem_poisson_130 cem_poisson_140 cem_poisson_150, star(* 0.1 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) stats(N r2_p) 
esttab cem_poisson_10_15y cem_poisson_20_15y cem_poisson_30_15y cem_poisson_40_15y cem_poisson_50_15y cem_poisson_60_15y cem_poisson_70_15y cem_poisson_80_15y cem_poisson_90_15y cem_poisson_100_15y cem_poisson_110_15y cem_poisson_120_15y cem_poisson_130_15y cem_poisson_140_15y cem_poisson_150_15y, star(* 0.1 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) stats(N r2_p) 
esttab cem_poisson_10_10y cem_poisson_20_10y cem_poisson_30_10y cem_poisson_40_10y cem_poisson_50_10y cem_poisson_60_10y cem_poisson_70_10y cem_poisson_80_10y cem_poisson_90_10y cem_poisson_100_10y cem_poisson_110_10y cem_poisson_120_10y cem_poisson_130_10y cem_poisson_140_10y cem_poisson_150_10y, star(* 0.1 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) stats(N r2_p) 
esttab cem_poisson_10_5y cem_poisson_20_5y cem_poisson_30_5y cem_poisson_40_5y cem_poisson_50_5y cem_poisson_60_5y cem_poisson_70_5y cem_poisson_80_5y cem_poisson_90_5y cem_poisson_100_5y cem_poisson_110_5y cem_poisson_120_5y cem_poisson_130_5y cem_poisson_140_5y cem_poisson_150_5y, star(* 0.1 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) stats(N r2_p) 
estimates clear
******************************

******************************
* Appendix A26
******************************
* Test of CEM sample balancing
probit deceased age_, cluster(cited) 
probit deceased age_ if cem_ == 1, cluster(cited) 
******************************

************************************************************





************************************************************
* Graphs
************************************************************
******************************
* Calculating variables for all graphs
******************************
gen radius = .
local i = 1
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
replace radius = `dis' in `i'
local i = `i' + 1
}

gen basic_poisson_d = .
gen basic_poisson_ci_lb = .
gen basic_poisson_ci_ub = .
gen basic_poisson_d_age60 = .
gen basic_poisson_ci_lb_age60 = .
gen basic_poisson_ci_ub_age60 = .
gen basic_poisson_d500 = .
gen basic_poisson_ci_lb500 = .
gen basic_poisson_ci_ub500 = .
gen basic_poisson_cons = .
gen basic_poisson_cons_d = .
gen basic_poisson_cons_age60 = .
gen basic_poisson_cons_d_age60 = .
gen basic_poisson_d_age60_2 = .
gen basic_poisson_ci_lb_age60_2 = .
gen basic_poisson_ci_ub_age60_2 = .

local i = 1
foreach dis of numlist 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 {
ppmlhdfe count_nsc_mindis`dis'_ deceased, absorb(cited) cluster(cited)
replace basic_poisson_d = _b[deceased] in `i'
replace basic_poisson_ci_lb = _b[deceased] + _se[deceased]*invt(e(df), 0.025) in `i'
replace basic_poisson_ci_ub = _b[deceased] + _se[deceased]*invt(e(df), 0.975) in `i'
ppmlhdfe count_nsc_mindis`dis'_ deceased if age_restriction == 1, absorb(cited) cluster(cited)
replace basic_poisson_d_age60 = _b[deceased] in `i'
replace basic_poisson_ci_lb_age60 = _b[deceased] + _se[deceased]*invt(e(df), 0.025) in `i'
replace basic_poisson_ci_ub_age60 = _b[deceased] + _se[deceased]*invt(e(df), 0.975) in `i'
ppmlhdfe count_nsc_mindis`dis'_ deceased if dummy500 == 1, absorb(cited) cluster(cited)
estimates store basic_poisson_`dis'_500
replace basic_poisson_d500 = _b[deceased] in `i'
replace basic_poisson_ci_lb500 = _b[deceased] + _se[deceased]*invt(e(df), 0.025) in `i'
replace basic_poisson_ci_ub500 = _b[deceased] + _se[deceased]*invt(e(df), 0.975) in `i'
ppmlhdfe count_nsc_mindis`dis'_ deceased
replace basic_poisson_cons = _b[_cons] in `i'
ppmlhdfe count_nsc_mindis`dis'_ deceased, absorb(cited) cluster(cited)
replace basic_poisson_cons_d = basic_poisson_cons +_b[deceased] in `i'
ppmlhdfe count_nsc_mindis`dis'_ deceased if age_restriction == 1
replace basic_poisson_cons_age60 = _b[_cons] in `i'
ppmlhdfe count_nsc_mindis`dis'_ deceased if age_restriction == 1, absorb(cited) cluster(cited)
replace basic_poisson_cons_d_age60 = basic_poisson_cons +_b[deceased] in `i'
ppmlhdfe count_nsc_mindis`dis'_ deceased if age_restriction2 == 1, absorb(cited) cluster(cited) // over 60
replace basic_poisson_d_age60_2 = _b[deceased] in `i'
replace basic_poisson_ci_lb_age60_2 = _b[deceased] + _se[deceased]*invt(e(df), 0.025) in `i'
replace basic_poisson_ci_ub_age60_2 = _b[deceased] + _se[deceased]*invt(e(df), 0.975) in `i'
local i = `i' + 1
}

gen time = .
local i = 1
foreach time of numlist 1/10 {
replace time = `time' in `i'
local i = `i' + 1
}
gen knowledgeflow_20 = .
gen knowledgeflow_20_ci_lb = .
gen knowledgeflow_20_ci_ub = .
local i = 1
foreach year of numlist 1/10 {
ppmlhdfe count_nsc_mindis20_y`year'_ deceased, absorb(cited) cluster(cited) 
replace knowledgeflow_20 = _b[deceased] in `i'
replace knowledgeflow_20_ci_lb = _b[deceased] + _se[deceased]*invt(e(df), 0.025) in `i'
replace knowledgeflow_20_ci_ub = _b[deceased] + _se[deceased]*invt(e(df), 0.975) in `i'
local i = `i' + 1
}
******************************

******************************
* Figure 1
******************************
* Citation penalty for deceased relative to living co-inventors by distance
* Panel A: analysis sample
scatter basic_poisson_d basic_poisson_ci_lb basic_poisson_ci_ub radius, msymbol(circle none none) msize(small small small) mcolor(navy navy navy) /// 
connect(direct direct direct) lpattern(solid dash dash) lcolor (navy navy navy) ///
legend(order(1 2) row(1) position(6) label(1 "β-coefficients") label(2 "95%-confidence-interval")) /// 
xscale(range(0.5/10.5) titlegap(3) outergap(2)) xlabel(10(10)150) xtitle("distance")  ///
yscale(titlegap(3)) ylabel(-0.50(0.1)0.10) ytitle("coefficient size") yline(0, lcolor(black)) ///
title("Relative citation differential" "for deceased vs. alive co-inventors by distance", size(medium)) 

* Panel B: analysis and premature death sample
scatter basic_poisson_d basic_poisson_ci_lb basic_poisson_ci_ub basic_poisson_d_age60 basic_poisson_ci_lb_age60 basic_poisson_ci_ub_age60 radius, msymbol(circle none none S none none) msize(small small small small small small) mcolor(navy navy navy cranberry cranberry cranberry) /// 
connect(direct direct direct direct direct direct) lpattern(solid longdash longdash solid shortdash shortdash) lcolor (navy navy navy cranberry cranberry cranberry) ///
legend(order(1 4 2 5) row(2) position(6) label(1 "β-coefficients") label(2 "95%-confidence-interval") label(4 "β-coefficients") label(5 "95%-confidence-interval") subtitle("Analysis sample                   Premature death sample") size(small)) /// 
xscale(range(0.5/10.5) titlegap(3) outergap(2)) xlabel(10(10)150) xtitle("distance")  ///
yscale(titlegap(3)) ylabel(-0.60(0.1)0.10) ytitle("coefficient size") yline(0, lcolor(black)) ///
title(" " "Relative citation differential" "for deceased vs. alive co-inventors by distance", size(medium))
******************************

******************************
* Figure 2
******************************
*Estimates for patents where next living co-inventor lives at least 500 miles away from home town of deceased inventor
scatter basic_poisson_d500 basic_poisson_ci_lb500 basic_poisson_ci_ub500 radius, msymbol(circle none none) msize(small small small) mcolor(navy black black) /// 
connect(direct direct direct) lpattern(solid dash dash) lcolor (navy black black) ///
legend(order(1 2) row(1) position(6) label(1 "β-coefficients") label(2 "95%-confidence-interval")) /// 
xscale(range(0.5/10.5) titlegap(3) outergap(2)) xlabel(10(10)150) xtitle("distance")  ///
yscale(titlegap(3)) ylabel(-2(0.5)0) ytitle("coefficient size") yline(0, lcolor(navy)) ///
title("Relative citation differential" "for deceased vs. alive co-inventors by distance", size(medium)) 
******************************

******************************
* Figure 3
******************************
* Citation penalty for deceased relative to living co-inventors within 20 miles in years 1 to 10 since grant
scatter knowledgeflow_20 knowledgeflow_20_ci_lb knowledgeflow_20_ci_ub time, msymbol(circle none none) msize(small small small) mcolor(navy black black) /// 
connect(direct direct direct) lpattern(solid dash dash) lcolor (navy black black) ///
legend(order(1 2) row(1) position(6) label(1 "β-coefficients") label(2 "95%-confidence-interval")) /// 
xscale(range(0.5/10.5) titlegap(3) outergap(2)) xlabel(1(1)10) xtitle("year since grant")  ///
yscale(titlegap(3)) ylabel(-0.8(0.2)0.1) ytitle("coefficient size") yline(0, lcolor(navy)) ///
title("Relative citation differential for deceased vs." "alive co-inventors within 20 miles by year", size(medium)) 	
******************************

******************************
* Appendix A14 
******************************
* Figure 1, Panel A, plus additional plot of estimated number of cites for deceased versus living co-inventors by distance
scatter basic_poisson_d basic_poisson_ci_lb basic_poisson_ci_ub radius, msymbol(circle none none) msize(small small small) mcolor(navy navy navy) /// 
connect(direct direct direct) lpattern(solid dash dash) lcolor (navy navy navy) ///
legend(order(1 2) row(1) position(6) label(1 "β-coefficients") label(2 "95%-confidence-interval")) /// 
xscale(range(0.5/10.5) titlegap(3) outergap(2)) xlabel(10(10)150) xtitle("distance")  ///
yscale(titlegap(3)) ylabel(-0.50(0.1)0.10) ytitle("coefficient size") yline(0, lcolor(black)) ///
title("Relative citation differential" "for deceased vs. alive co-inventors by distance", size(medium)) 

scatter basic_poisson_cons basic_poisson_cons_d radius, msymbol(S circle) msize(small small) mcolor(navy navy) /// 
connect(direct direct) lpattern(dash solid) lcolor (navy navy) ///
legend(order(1 2) row(1) position(6) label(1 "alpha") label(2 "alpha + β-coefficient")) /// 
xscale(range(0.5/10.5) titlegap(3) outergap(4)) xlabel(10(10)150) xtitle("distance")  ///
yscale(titlegap(3)) ylabel(0.60(0.2)1.8) ytitle("coefficient size") ///
title("Citations for deceased and alive co-inventors" "by distance", size(medium))
******************************

******************************
* Appendix A15
******************************
* Figure 1, Panel B, plus additional plot of estimated number of cites for deceased versus living co-inventors by distance
scatter basic_poisson_d basic_poisson_ci_lb basic_poisson_ci_ub basic_poisson_d_age60 basic_poisson_ci_lb_age60 basic_poisson_ci_ub_age60 radius, msymbol(circle none none S none none) msize(small small small small small small) mcolor(navy navy navy cranberry cranberry cranberry) /// 
connect(direct direct direct direct direct direct) lpattern(solid longdash longdash solid shortdash shortdash) lcolor (navy navy navy cranberry cranberry cranberry) ///
legend(order(1 4 2 5) row(2) position(6) label(1 "β-coefficients") label(2 "95%-confidence-interval") label(4 "β-coefficients") label(5 "95%-confidence-interval") subtitle("Analysis sample                   Premature death sample") size(small)) /// 
xscale(range(0.5/10.5) titlegap(3) outergap(2)) xlabel(10(10)150) xtitle("distance")  ///
yscale(titlegap(3)) ylabel(-0.60(0.1)0.10) ytitle("coefficient size") yline(0, lcolor(black)) ///
title(" " "Relative citation differential" "for deceased vs. alive co-inventors by distance", size(medium))

scatter basic_poisson_cons basic_poisson_cons_d basic_poisson_cons_age60 basic_poisson_cons_d_age60 radius, msymbol(S circle S circle) msize(small small small small) mcolor(navy navy cranberry cranberry) /// 
connect(direct direct direct direct) lpattern(dash solid dash solid) lcolor (navy navy cranberry cranberry) ///
legend(order(1 3 2 4) row(2) position(6) label(1 "alpha") label(2 "alpha + β-coefficient") label(3 "alpha") label(4 "alpha + β-coefficient") subtitle("Analysis sample                   Premature death sample") size(small)) /// 
xscale(range(0.5/10.5) titlegap(3) outergap(2)) xlabel(10(10)150) xtitle("distance") ///
yscale(titlegap(3)) ylabel(0.60(0.2)1.8) ytitle("coefficient size") ///
title("Citations for deceased and alive co-inventors" "by distance", size(medium)) 
******************************

******************************
* Appendix A16
******************************
* Figure illustrating baseline estimates for premature death sample and complementary sample of deaths at age 61 or higher
scatter basic_poisson_d_age60 basic_poisson_ci_lb_age60 basic_poisson_ci_ub_age60 basic_poisson_d_age60_2 basic_poisson_ci_lb_age60_2 basic_poisson_ci_ub_age60_2 radius, msymbol(circle none none S none none) msize(small small small small small small) mcolor(navy navy navy cranberry cranberry cranberry) /// 
connect(direct direct direct direct direct direct) lpattern(solid longdash longdash solid shortdash shortdash) lcolor (navy navy navy cranberry cranberry cranberry) ///
legend(order(1 4 2 5) row(2) position(6) label(1 "β-coefficients") label(2 "95%-confidence-interval") label(4 "β-coefficients") label(5 "95%-confidence-interval") subtitle("Deceased inventors under 60   Deceased inventors above 60") size(small)) /// 
xscale(range(0.5/10.5) titlegap(3) outergap(2)) xlabel(10(10)150) xtitle("distance")  ///
yscale(titlegap(3)) ylabel(-0.70(0.1)0.10) ytitle("coefficient size") yline(0, lcolor(black)) ///
title("Relative citation differential" "for deceased vs. alive co-inventors by distance", size(medium))
******************************

************************************************************

exit
